// AdminWrongQuestionServiceImpl.java
package com.scuec.groupfive.service.impl;

import com.github.pagehelper.PageHelper;
import com.scuec.groupfive.mapper.AdminWrongQuestionMapper;
import com.scuec.groupfive.service.AdminWrongQuestionService;
import com.scuec.groupfive.vo.AdminWrongQuestionDetailVO;
import com.scuec.groupfive.vo.AdminWrongQuestionOverviewVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;

@Service
public class AdminWrongQuestionServiceImpl implements AdminWrongQuestionService {

    @Autowired
    private AdminWrongQuestionMapper wrongQuestionMapper;

    @Override
    public List<AdminWrongQuestionOverviewVO> getWrongQuestionOverview(
            Long userId, Integer subjectId, Date startDate, Date endDate,
            Integer page, Integer size, String sort) {

        // 添加分页参数
        PageHelper.startPage(page + 1, size); // page从0开始，PageHelper从1开始
        return wrongQuestionMapper.getWrongQuestionOverview(userId, subjectId, startDate, endDate, sort);
    }

    @Override
    public AdminWrongQuestionDetailVO getWrongQuestionDetail(Long userId, String wrongId) {
        return wrongQuestionMapper.getWrongQuestionDetail(userId, wrongId);
    }
    @Override
    public long countWrongQuestions(Long userId, Integer subjectId, Date startDate, Date endDate) {
        return wrongQuestionMapper.countWrongQuestions(userId, subjectId, startDate, endDate);
    }
}